package study.designpattern.flyweight;

import java.util.HashMap;
import java.util.Map;

public class CoffeeFlavorFactory {
    private Map<String, CoffeeFlavor> flavors = new HashMap<String, CoffeeFlavor>();
    
    public CoffeeFlavor getCoffeeFlavor(String flavor){
        CoffeeFlavor coffeeFlavor = flavors.get(flavor);
        if(coffeeFlavor == null){
            coffeeFlavor = new CoffeeFlavor(flavor);
            flavors.put(flavor, coffeeFlavor);
        }
        return coffeeFlavor;
    }
    
    public int getTotalCoffeeFlavorsMade() {
        return flavors.size();
    }
}
